package com.yingjia.yingjiauniversity.rxbus;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * <订阅通用rx>
 *
 * @author: guoxiangxun
 * @date: 17-6-16 下午3:44
 * @version: v1.0
 */
public class ScheduleTransformer<T> implements ObservableTransformer<T, T> {

    private static ScheduleTransformer instance = new ScheduleTransformer();

    public static <T> ScheduleTransformer<T> get() {
        return instance;
    }

    @Override
    public ObservableSource<T> apply(Observable<T> upstream) {
        return upstream.subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
}
